package cn.kgc.junketing.provider.utli;

import org.apache.commons.codec.digest.DigestUtils;

public class MD5Utils {
    //  盐
    private static final String SALT = "s1a2l3t4";

    public static String md5(String src) {
        String md5Hex = DigestUtils.md5Hex(src);
        return md5Hex;
    }

    //  第一次加密
    public static String md5First(String src) {
        src = "" + SALT.charAt(0) + SALT.charAt(1) + src + SALT.charAt(4) + SALT.charAt(5);
        String firstMd5 = md5(src);
        System.out.println(firstMd5);
        return firstMd5;
    }

    //  第二次md5加密
    public static String md5Second(String src, String salt) {
        src = "" + salt.charAt(0) + salt.charAt(1) + src + salt.charAt(4) + salt.charAt(5);
        String secondMd5 = md5(src);
        return secondMd5;
    }

    public static String md5DBPwd(String pwd, String salt) {
        String md5First = md5First(pwd);
        String md5Second = md5Second(md5First, salt);
        return md5Second;
    }
}
